package pers.amos.edu.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.amos.edu.pojo.SchoolMajor;
import pers.amos.edu.service.SchoolMajorService;

import java.util.List;

/**
 * @author amos wong
 * @create 2020-02-01 19:09
 */

@RestController
@RequestMapping("/edu/major")
/**
 * 查询专业的接口
 */
@Api(tags = "查询学校所有专业的接口")
public class SchoolMajorController {

    @Autowired
    private SchoolMajorService majorService;

    /**
     * 通过学校id查询学校所有专业的接口
     * @param id 学校的id
     * @return
     */
    @ApiOperation("查询某学校的所有专业")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "学校的id"),
            @ApiImplicitParam(name = "openId", value = "可以不传openId")})
    @GetMapping("/{id}")
    public ResponseEntity<List<SchoolMajor>> getMajorBySchoolId(@PathVariable("id") Integer id, String openId) {
        List<SchoolMajor> majorList = majorService.getMajorBySchoolId(id, openId);
        return ResponseEntity.ok(majorList);
    }
}
